package contents.entities;

import java.util.Comparator;

public class SubstitutionItem {
    public static class ByClassNameAndTimeComparator implements Comparator {
        public int compare(Object object1, Object object2) {
            SubstitutionItem substitution1 = (SubstitutionItem) object1;
            SubstitutionItem substitution2 = (SubstitutionItem) object2;
            
            String className1 = substitution1.getClassName();
            String className2 = substitution2.getClassName();
                
            if (!className1.equals(className2)) {
                return className1.compareTo(className2);
            } else {
                Integer time1 = substitution1.getLesson();
                Integer time2 = substitution2.getLesson();
                    
                return time1.compareTo(time2);
            }
        }   
    }
    
    private int substitutionId;
    private String className;
    private Integer lesson;
    private Subject subject;
    private Teacher missingTeacher;
    private Teacher substitutingTeacher;
    
    public SubstitutionItem(int substitutionId, String className, Integer lesson, Subject subject, Teacher missingTeacher, Teacher substitutingTeacher) {
        this(className, lesson, subject, missingTeacher, substitutingTeacher);
        this.substitutionId = substitutionId;
    }
    
    public SubstitutionItem(String className, Integer lesson, Subject subject, Teacher missingTeacher, Teacher substitutingTeacher) {
        this.className = className;
        this.lesson = lesson;
        this.subject = subject;
        this.missingTeacher = missingTeacher;
        this.substitutingTeacher = substitutingTeacher;
    }
    
    public int getSubstitutionId() {
        return substitutionId;
    }

    public String getClassName() {
        return className;
    }

    public Integer getLesson() {
        return lesson;
    }

    public Subject getSubject() {
        return subject;
    }
    
    public Teacher getMissingTeacher() {
        return missingTeacher;
    }   

    public Teacher getSubstitutingTeacher() {
        return substitutingTeacher;
    }

    /*
     * For purpose of web service.
     */
    public void setClassName(String className) {
        this.className = className;
    }

    /*
     * For purpose of web service.
     */
    public void setLesson(Integer lesson) {
        this.lesson = lesson;
    }

    /*
     * For purpose of web service.
     */
    public void setMissingTeacher(Teacher missingTeacher) {
        this.missingTeacher = missingTeacher;
    }

    /*
     * For purpose of web service.
     */
    public void setSubject(Subject subject) {
        this.subject = subject;
    }

    /*
     * For purpose of web service.
     */
    public void setSubstitutingTeacher(Teacher substitutingTeacher) {
        this.substitutingTeacher = substitutingTeacher;
    }

    /*
     * For purpose of web service.
     */
    public void setSubstitutionId(int substitutionId) {
        this.substitutionId = substitutionId;
    }
}
